jsx3.Class.defineClass(
	"ux.cdb.admin.dataautomate.MatrixUpdater",
	ux.cdb.admin.dataautomate.GenericUpdater, null,
	function (block) {

		block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML) {
			//call constructor for super class (the super expects the name of the object and the function that it is an instance of)
			this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
		};

		block.prototype.applyData = function(data) {
			var me = this;
			var dataArray = data[this.uxdataatt];
			if(!(dataArray instanceof Array)){
                /* @JSC :: begin DEBUG */
				console.log('Please assign a Array object for matrix updater:'+this.getName());
                /* @JSC :: end */
				return;
			}
			
			var cdf = jsx3.xml.CDF.Document.newDocument();
			for(var i=0;i<dataArray.length;i++){
				var dataObj = dataArray[i];
                if(!dataObj) { dataObj = {} };
				if(!dataObj.jsxid) dataObj.jsxid = jsx3.xml.CDF.getKey();
				cdf.insertRecord(dataObj);
			}
			this.getDescendantOfName('matrix').setXMLString(cdf.toString());
			this.getDescendantOfName('matrix').resetCacheData();
			this.getDescendantOfName('matrix').repaint();
			
		};
		
		block.prototype.extractData = function(){
			//return this.getDescendantOfName("txtValue").getValue();
			var xml = this.getDescendantOfName('matrix').getXML();
			
			var data = [];
			if(xml == null)	return data;
			var iter = xml.selectNodeIterator('//record');
			while(iter.hasNext()){
				var obj = {};
				var record = iter.next();
				var iterAtts = record.getAttributes().iterator();
	            while(iterAtts.hasNext()) {
	                var att = iterAtts.next();
	                obj[att.getNodeName()] = att.getValue();
	            }
				data.push(obj);
			}
			return data;
		};
		
		block.prototype.doValidate = function(){
			//Needn't to be implemented in matrix
			return null;
		}
		
		//methods from IExtractor interface for support validation correctly
		block.prototype._validateFailedUI = function(failed,message){
			//Needn't to be implemented in matrix
		};
		
	});